# -*- coding: utf-8 -*-
#
# Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
# Copyright (C) 2017-2019 THL A29 Limited, a Tencent company. All rights reserved.
# Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://opensource.org/licenses/MIT
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#
# Generated by Django 1.11.5 on 2018-10-10 02:12
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import jsonfield.fields


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Chart',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('name', models.CharField(max_length=50)),
                ('description', models.CharField(max_length=1000)),
                ('icon', models.TextField()),
                ('deleted', models.BooleanField(default=False)),
                ('deleted_at', models.DateTimeField(blank=True, null=True)),
            ],
            options={
                'db_table': 'helm_chart',
            },
        ),
        migrations.CreateModel(
            name='ChartRelease',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('answers', jsonfield.fields.JSONField(default=[], null=True)),
                ('customs', jsonfield.fields.JSONField(default=[], null=True)),
                ('valuefile', models.TextField(help_text='yaml format')),
                ('short_name', models.CharField(max_length=6)),
                ('app_id', models.IntegerField(db_index=True, default=-1, verbose_name='App ID')),
                ('release_type', models.CharField(choices=[('release', 'release'), ('rollback', 'rollback')], default='release', max_length=10)),
                ('chart', models.ForeignKey(db_constraint=False, null=True, on_delete=django.db.models.deletion.SET_NULL, to='helm.Chart')),
            ],
            options={
                'db_table': 'helm_chart_release',
            },
        ),
        migrations.CreateModel(
            name='ChartVersion',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('name', models.CharField(max_length=50)),
                ('home', models.CharField(max_length=200, null=True)),
                ('description', models.CharField(max_length=1000)),
                ('engine', models.CharField(max_length=20)),
                ('created', models.DateTimeField()),
                ('maintainers', jsonfield.fields.JSONField(default=[], null=True)),
                ('sources', jsonfield.fields.JSONField(default=[], null=True)),
                ('urls', jsonfield.fields.JSONField(default=[])),
                ('files', jsonfield.fields.JSONField(default={})),
                ('questions', jsonfield.fields.JSONField(default={})),
                ('keywords', models.CharField(blank=True, max_length=200, null=True)),
                ('version', models.CharField(max_length=50)),
                ('digest', models.CharField(max_length=64)),
                ('chart', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='versions', to='helm.Chart')),
            ],
            options={
                'db_table': 'helm_chart_version',
            },
        ),
        migrations.CreateModel(
            name='ChartVersionSnapshot',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('name', models.CharField(max_length=50)),
                ('home', models.CharField(max_length=200, null=True)),
                ('description', models.CharField(max_length=1000)),
                ('engine', models.CharField(max_length=20)),
                ('created', models.DateTimeField()),
                ('maintainers', jsonfield.fields.JSONField(default=[], null=True)),
                ('sources', jsonfield.fields.JSONField(default=[], null=True)),
                ('urls', jsonfield.fields.JSONField(default=[])),
                ('files', jsonfield.fields.JSONField(default={})),
                ('questions', jsonfield.fields.JSONField(default={})),
                ('version', models.CharField(max_length=50)),
                ('version_id', models.IntegerField(default=-1, help_text='record the chart version which this snapshot comes from')),
                ('digest', models.CharField(max_length=64, unique=True)),
            ],
            options={
                'db_table': 'helm_chart_version_snapshot',
            },
        ),
        migrations.CreateModel(
            name='Repository',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('url', models.URLField(verbose_name='URL')),
                ('name', models.CharField(max_length=32, verbose_name='Name')),
                ('description', models.CharField(max_length=512)),
                ('project_id', models.CharField(max_length=32, verbose_name='ProjectID')),
                ('provider', models.CharField(max_length=32, verbose_name='Provider')),
                ('is_provisioned', models.BooleanField(default=False, verbose_name='Provisioned?')),
                ('refreshed_at', models.DateTimeField(null=True)),
                ('commit', models.CharField(max_length=64, null=True)),
                ('branch', models.CharField(max_length=30, null=True)),
                ('storage_info', jsonfield.fields.JSONField(default={})),
            ],
            options={
                'db_table': 'helm_repository',
            },
        ),
        migrations.CreateModel(
            name='RepositoryAuth',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(choices=[('BASIC', 'BasicAuth')], max_length=16, verbose_name='Type')),
                ('credentials', jsonfield.fields.JSONField(default={}, verbose_name='Credentials')),
                ('role', models.CharField(max_length=16, verbose_name='Role')),
                ('repo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='auths', to='helm.Repository')),
            ],
            options={
                'db_table': 'helm_repo_auth',
            },
        ),
        migrations.AlterUniqueTogether(
            name='repository',
            unique_together=set([('project_id', 'name')]),
        ),
        migrations.AddField(
            model_name='chartrelease',
            name='chartVersionSnapshot',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='helm.ChartVersionSnapshot'),
        ),
        migrations.AddField(
            model_name='chartrelease',
            name='repository',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='helm.Repository'),
        ),
        migrations.AddField(
            model_name='chart',
            name='defaultChartVersion',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='default_chart_version', to='helm.ChartVersion'),
        ),
        migrations.AddField(
            model_name='chart',
            name='repository',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='helm.Repository'),
        ),
        migrations.AlterUniqueTogether(
            name='chartversion',
            unique_together=set([('chart', 'version', 'digest')]),
        ),
        migrations.AlterUniqueTogether(
            name='chart',
            unique_together=set([('name', 'repository')]),
        ),
    ]
